package net.starwifi.duobao.service.impl;


import net.starwifi.duobao.service.JmsSendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Service;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;


/**
 * Created by Administrator on 2016/1/29.
 */
@Service
public class JmsSendServiceImpl implements JmsSendService {


    @Autowired
    private JmsTemplate jmsTemplate;

    @Override
    public void sendTextMessage(final String textMsg) {
        jmsTemplate.send(new MessageCreator() {
            public Message createMessage(Session session) throws JMSException {
                TextMessage message = session.createTextMessage();
                message.setText(textMsg);
                return message;
            }
        });
    }

   /* @Override
    public void sendTextMessage(final String textMsg) {
     
    }*/
}
